// 当前这个模块：api进行统一管理
import requests from './request';
// mock请求 当前这个模块：mock进行统一管理
import mockRequests from './mockAjax';
// ajax请求
//三级联动的接口
// /api/product/getBaseCategoryList  get请求 无参数
export const reqCategoryList = () => {
    // 发情求:axios 发请求返回结果是Promise对象
    return requests({ url: '/product/getBaseCategoryList', method: 'get' });
}

// 获取搜索模块的接口 /api/list
// 当前这个接口，给服务器传递参数params，至少是一个空对象
export const reqPostSelectorInfo = (params) => {
        return requests({ url: '/list', method: 'post', data: params });
    }
    // 参数示例
    // {
    //     "category3Id": "61",
    //     "categoryName": "手机",
    //     "keyword": "小米",
    //     "order": "1:desc",
    //     "pageNo": 1,
    //     "pageSize": 10,
    //     "props": ["1:1700-2799:价格", "2:6.65-6.74英寸:屏幕尺寸"],
    //     "trademark": "4:小米"
    //   }

// 获取产品详情页数据的接口 URL:/api/item/{skuId} 请求发送get
export const reqListsItem = (skuId) => {
    return requests({ url: `/item/${skuId}`, method: 'get' });
}

// 将添加产品到购物车中（获取更新某一产品的个数）
// /api/cart/addToCart/{skuId}/{skuNum} post请求
export const reqAddShopCart = (skuId, skuNum) => {
    return requests({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: 'post' })
}

// 获取购物车的接口
// /api/cart/cartList method:get
export const reqCartList = () => {
    return requests({ url: '/cart/cartList', method: 'get' })
}

// 删除购物车列表数据接口
// /api/cart/deleteCart/{skuId}
export const reqDeleteCart = (skuId) => {
        return requests({ url: `/cart/deleteCart/${skuId}`, method: 'delete' })
    }
    // 8. 切换商品选中状态
    // /api/cart/checkCart/{skuID}/{isChecked}
export const reqCheckCart = (skuId, isChecked) => {
        return requests({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' })
    }
    // 获取验证码
    // /api/user/passport/sendCode/{phone}
export const reqGetCode = (phone) => {
    return requests({ url: `/user/passport/sendCode/${phone}`, method: 'get' })
}

// 注册用户
// /api/user/passport/register
export const reqGetRegister = (data) => {
    return requests({ url: `/user/passport/register`, data, method: 'post' })
}

// 登录用户
// /api/user/passport/login
export const reqGetLogin = (data) => {
    return requests({ url: '/user/passport/login', data, method: 'post' })
}

// 使用token获取用户信息
// /user/passport/auth/getUserInfo
export const reqGetUserInfo = () => {
        return requests({ url: '/user/passport/auth/getUserInfo', method: 'get' })
    }
    // 退出登录
    // /api/user/passport/logout get
export const reqLogout = () => {
        return requests({ url: '/user/passport/logout', method: 'get' })
    }
    // 获取用户地址信息
    // /api/user/userAddress/auth/findUserAddressList
export const reqFindUser = () => {
        return requests({ url: '/user/userAddress/auth/findUserAddressList', method: 'get' })
    }
    // 获取订单交易页信息
    // /api/order/auth/trade
export const reqTradeInfo = () => {
    return requests({ url: '/order/auth/trade', method: 'get' })
}


// 提交订单的接口
// /api/order/auth/submitOrder?tradeNo={tradeNo} POST
export const reqSubmitOrder = (tradeNo, data) => {
        return requests({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, data, method: 'post' })
    }
    // 获取支付信息
    // /api/payment/weixin/createNative/{orderId}
export const reqPayment = (orderId) => {
    return requests({ url: `/payment/weixin/createNative/${orderId}`, method: 'get' })
}

// mock请求
// banner轮播图接口
export const reqGetBannerList = () => {
        // 发情求:axios 发请求返回结果是Promise对象
        return mockRequests({ url: '/banner', method: 'get' });
    }
    // floor轮播图接口
export const reqGetFloorList = () => {
    // 发情求:axios 发请求返回结果是Promise对象
    return mockRequests({ url: '/floor', method: 'get' });
}